serde
extensions for the http
crate types
Allows serializing and deserializing the following types from http
:
Response
Request
HeaderMap
StatusCode
Uri
Method
HeaderName
HeaderValue
uri::Authority
uri::Scheme
uri::PathAndQuery
Version
- Generic
HeaderMap<T>
where the item is not aHeaderValue
Allows serializing and deserializing the above types wrapped in the following std
container types:
Option
Result
in theOk
positionVec
VecDeque
LinkedList
HashMap
as theKey
for all exceptHeaderMap
,Request
, andResponse
. As theValue
for all types.BTreeMap
as theKey
only forHeaderValue
,StatusCode
, andVersion
. As theValue
for all types.HashSet
for all exceptHeaderMap
,Request
, andResponse
BTreeSet
only forHeaderValue
,StatusCode
, andVersion
Installation
Run the following Cargo command in your project directory:
Or add the following line to your Cargo.toml:
= "1.0.2"
Usage
This library is intended to be used with serde
's derive
feature.
Fields should use the appropriate #[serde(with = "...")]
annotation for that
type. Full examples are provided in each module section of the docs.
use *;
use *;
use ;
This library can also be used to manually De
/Serialize
types if given a
De
/Serializer
. For example, when using serde_json
:
let uri = default;
let serialized = serialize.unwrap;
let deserialized = deserialize.unwrap;
assert_eq!;
let mut responses: = vec!;
let serialized =
serialize
.unwrap;
let mut deserialized: =
deserialize.unwrap;
let original = responses.remove.into_parts;
let deserialized = deserialized.remove.into_parts;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
Acknowledgements
This crate is heavily inspired by Kornel's http-serde
.